package com.d3works.apps.crm.service.config;

import com.d3works.apps.base.db.Company;
import com.d3works.apps.crm.db.CrmConfig;
import com.d3works.apps.crm.exception.CrmExceptionMessage;
import com.d3works.exception.D3worksException;
import com.d3works.exception.db.repo.TraceBackRepository;
import com.d3works.i18n.I18n;

public class CrmConfigService {

  public CrmConfig getCrmConfig(Company company) throws D3worksException {
    CrmConfig crmConfig = company.getCrmConfig();

    if (crmConfig == null) {
      throw new D3worksException(
          TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
          I18n.get(CrmExceptionMessage.CRM_CONFIG_1),
          company.getName());
    }
    return crmConfig;
  }
}
